﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;

namespace ADSync2.EngineComponents
{
	/// <summary>
	/// Class storing FIFO queue of membership for execution
	/// </summary>
	public class Jobs
	{
		#region Preferences
		public ConcurrentQueue<KeyValuePair<String, MembershipAction>> JobsQueue
		{
			get;
			set;
		}

		#endregion

		#region Constructors
		public Jobs()
		{
			this.JobsQueue = new ConcurrentQueue<KeyValuePair<String, MembershipAction>>();
		}
		#endregion

		#region Public Methods
		public void AddJob(String GroupDn, MembershipAction MembershipAction)
		{
			try
			{
				this.JobsQueue.Enqueue(new KeyValuePair<string, MembershipAction>(GroupDn, MembershipAction));
			}
			catch (Exception eX)
			{
				throw new Exception(string.Format("{0}::{1}", new StackFrame(0, true).GetMethod().Name, eX.Message));
			}
		}
		#endregion
	}


}
